package com.itheima.mapper;

import com.itheima.pojo.BrowseGoodsRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrowseGoodsRecordMapper {
    @Insert("insert into browse_goods_record (item_name, duration, user_id) values(#{itemName}, #{duration}, #{userId})")
    @ResultMap("browseGoodsRecordResultMap")
    void add(BrowseGoodsRecord browseGoodsRecord);

    @Select("select * from browse_goods_record where user_id = #{userId}")
    @ResultMap("browseGoodsRecordResultMap")
    List<BrowseGoodsRecord> selectByUserId(Integer userId);

    @Select("SELECT COUNT(item_name) AS total_quantity FROM browse_goods_record WHERE item_name = #{itemName}")
    @ResultMap("browseGoodsRecordResultMap")
    Integer selectByItemName(String itemName);
}
